import httpInstance from "@/utils/http";

// 获取地址列表
export const getAddressListAPI = async() => {
  try {
    const res = await httpInstance.post("/api/address");
    return res;
  } catch (error) {
    ElMessage.error(res.massage);
    throw new Error(error);
  }
}

// 添加地址
export const addAddressAPI = async(data) => {
  try {
    const res = await httpInstance.post("/api/address/add", data);
    return res;
  } catch (error) {
    ElMessage.error(res.massage);
    throw new Error(error);
  }
}

// 删除地址
export const deleteAddressAPI = async(id) => {
  try {
    const res = await httpInstance.delete( `/api/address/${id}`);
    return res;
  } catch (error) {
    ElMessage.error(res.massage);
    throw new Error(error);
  }
}

// 修改地址
export const updateAddressAPI = async(id, data) => {
  try {
    const res = await httpInstance.put( `/api/address/${id}`, data);
    return res;
  } catch (error) {
    ElMessage.error(res.massage);
    throw new Error(error);
  }
}

